package com.opticon.vaadinR.core.conf;

import com.opticon.vaadinR.interfaces.VaadinRApplication;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

import java.io.File;

/**
 * This class is a
 */
public class CoreConfiguration {

    /**
     * Properties instance to manage the properties of the library.
     */
    private static PropertiesConfiguration input;
    private static VaadinRApplication VaadinRApplication;

    /**
     * Static initiatlizer.
     */
    static {
        try {
            input = new PropertiesConfiguration("config/core.properties");
        } catch (ConfigurationException e) {
            e.printStackTrace();
        }
    }

    // Return the filename for the vaadinR output directory.
    public static String getRScriptDefault(){
        return getRScript("default");
    }

    // Return the filename for the vaadinR output directory.
    public static String getRScript(String aScriptName){
        String lRScript = input.getString("vaadinR.script." + aScriptName);
        return lRScript;
    }



    public static File getTmpDir(){
        return new File(input.getString("vaadinR.tmpdir"));
    }


    public static void setApplication(VaadinRApplication aVaadinRApplication) {
        VaadinRApplication = aVaadinRApplication;
    }

    public static VaadinRApplication getVaadinRApplication() {
        return VaadinRApplication;
    }
}
